package jjn.round1;

/**
 * @author Jiang Jining
 * @since 2023-05-14 23:30
 */
public class LeetCode121_BestTimeToBuyAndSellStock {
    public int maxProfit(int[] prices) {
        int min = Integer.MAX_VALUE;
        int maxProfit = 0;
        for (int price : prices) {
            min = Math.min(price, min);
            maxProfit = Math.max(maxProfit, price - min);
        }
        return maxProfit;
    }
}
